package com.ruoyi.web.service.yiqingDetailsService.Impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.web.domain.Region;
import com.ruoyi.web.mapper.RegionMapper;
import com.ruoyi.web.service.yiqingDetailsService.RegionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 为地区表提供服务支持
 */
@Service
public class RegionServiceImpl extends ServiceImpl<RegionMapper, Region> implements RegionService {

    @Autowired
    RegionMapper regionMapper;

    @Override
    public List<Region> getAreaList(int id) {
        List<Region> list = lambdaQuery().eq(Region::getParentId, id).list();
        list.stream().forEach(region -> {
            region.getParam().put("children",lambdaQuery().eq(Region::getParentId, region.getId()).list());
        });

        return list;
    }


}
